package com.example.demo.Controller;

import com.example.demo.Service.BookService;
import com.example.demo.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/book")
@RestController
public class BookListUpdateController {

    @Autowired
    BookService bookService;

    @RequestMapping("/getBook")
    public BookInfo getBookById(Integer bookId){


        if(bookId==null){
            return null;
        }
        System.out.println(bookId);
        BookInfo bookInfo = new BookInfo();
        bookInfo =  bookService.selectBookById(bookId);
        return  bookInfo;
    }
    @RequestMapping("/update")
    public Boolean updateBook(BookInfo bookInfo){
        boolean flag =  bookService.updateBook(bookInfo);
        if(flag==true){
            return true;
        }
        return false;

    }
}
